package com.hbnu.iostream;

import java.io.File;
import java.io.IOException;

public class FileOperator1 {
    public static void main(String[] args) {
//        String path = "C:\\Users\\TX\\IdeaProjects\\javalean\\src\\com\\hbnu\\iostream\\test.txt";      //此句在Windows下有效
        //获取当前系统的分隔符，适用于各种系统
        String path = "C:" + File.separator +"Users" + File.separator +"TX" + File.separator +"IdeaProjects" + File.separator +"javalean" + File.separator +"src" + File.separator +"com" + File.separator +"hbnu" + File.separator +"iostream" + File.separator +"test.txt";

        File file = new File(path);
        try {
            boolean result = file.createNewFile();
            if (!result){
                System.out.println("文件创建失败......");
            }
        } catch (IOException e) {
            System.out.println("文件创建失败！！！");
        }

    }
}
